﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Account_RegisterVerifyPn : CommPageBase
{
    const string pnCodeKey = "ACCOUNT_REGISTERVERIFYPN_PNCODE";
    const string pnCodeTimesKey = "ACCOUNT_REGISTERVERIFYPN_PNCODE_TIMES";
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public string SendPhoneVerifyCode(string phoneNumber,string imageCode)
    {
        if (!PageHelper.IsCorrectVerifyCode(imageCode))
        {
            return "ERRIMGCODE";
        }
        int times = 1;
        if (Session[pnCodeTimesKey] != null)
        {
            times = Convert.ToInt32(Session[pnCodeTimesKey]) + 1;
        }

        if (times > 10)
        {
            return "MAXTIMES";
        }
        else
        {
            Session[pnCodeTimesKey] = times;
        }

        string pnCode = "1112";
        Session[pnCodeKey] = pnCode;
        return "OK";
    }

    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public bool IsCorrectPhoneVerifyCode(string code)
    {
        return Session[pnCodeKey] == null || Session[pnCodeKey].ToString() == code;
    }
}